<template>
    <div style="background:#fff">
        <van-nav-bar
            title="修改密码"
            left-arrow
            @click-left="onClickLeft"
            />
        <van-form >
            <van-field
                v-model="mobile"
                center
                clearable
                placeholder="请输入手机号"
                >
                <template #button>
                    <van-button size="small" type="primary" @click="sendsCode">发送验证码</van-button>
                </template>
            </van-field>
            <van-field
                v-model="code"
                name="验证码"
                placeholder="请输入验证码"
                :rules="[{ required: true, message: '请输入验证码' }]"
            />
            <van-field
                v-model="password"
                type="password"
                placeholder="请输入密码"
                :rules="[{ required: true, message: '请输入密码' }]"
            />
            <div style="margin: 16px;">
                <van-button round block type="info" @click="submitPass">提交</van-button>
            </div>
            </van-form>
    </div>
</template>

<script>
import { sendCode,sendPassword } from "../request/http.js";
export default {
  data() {
    return {
      code: "",
      mobile: "",
      password: ""
    };
  },
  mounted() {},
  methods: {
      onClickLeft(){
          this.$router.push('/')
      },
    sendsCode() {
        sendCode({mobile:this.mobile,sms_type:'getPassword'}).then(res=>{
            console.log(res);
        })
    },
    submitPass(){
        sendPassword({mobile:this.mobile,password:this.password,sms_code:this.code}).then(res=>{
            console.log(res);
            if(res.data.code==200){
                this.$router.push('/my')
            }
        })
    }
  }
};
</script>

<style lang="sass" scoped>

</style>